package com.gxa.user.service.order.util;/**
 * @author JunYu
 * @create 2022-10-09--18:02
 */

import com.gxa.common.utils.DateUtils;
import com.gxa.user.pojo.order.SysOrder;
import com.gxa.user.vo.OrderInfo;
import jdk.internal.dynalink.beans.StaticClass;

/**
 * @program: take-out-project-shop
 *
 * @description: 工具类
 *
 * @author: JunYu
 *
 * @create: 2022-10-09 18:02
 **/

public class GenerateOrderByOrderInfo {
    public static SysOrder generateOrderByOrderInfo(OrderInfo orderInfo , long orderId){
        SysOrder sysOrder = new SysOrder();
        //设置订单id
        sysOrder.setOrderId(orderId);
        //设置顾客id
        sysOrder.setCustomerId(orderInfo.getUserId());
        //设置活动id
        sysOrder.setDiscountId(orderInfo.getDiscountId());
        //设置支付币种(暂定)
        //交易编号
        //设置商家编号
        sysOrder.setSupplierId(orderInfo.getShopId());
        //设置活动id
        sysOrder.setDiscountId(orderInfo.getDiscountId());
        //设置发票模板id
        sysOrder.setInvoiceId(orderInfo.getInvoiceId());
        //设置订单取货地址
        sysOrder.setAddressId(orderInfo.getAddressId());
        //设置创建时间
        sysOrder.setCreateTime(DateUtils.generateCurrentTimeInString());
        //设置订单类型（外卖订单）
        sysOrder.setOrderType(0);
        //设置到达时间
        sysOrder.setDeliveryTime(DateUtils.generateFewsMinutesLaterInString(orderInfo.getArriveTime()));
        //设置配送方式（待定）
        //设置餐具数量
        sysOrder.setTableware(orderInfo.getTableWare());
        //设置订单备注
        sysOrder.setRemarks(orderInfo.getRemark());
        //设置开具发票
        sysOrder.setHasInvoice(orderInfo.getHasInvoice());
        //设置订单状态（默认未支付）
        sysOrder.setOrderStatus(1);
        //设置退款状态(默认为未退款)
        sysOrder.setRefundStatus(0);
        //设置打包费
        sysOrder.setPackingFee(orderInfo.getPackingFee());
        //设置配送费
        sysOrder.setDeliveryFee(orderInfo.getDeliveryFee());
        return sysOrder;
    }
}
